package org.csmzxy.class2333;

public class 波那栔 {

    public static void main(String[] args){
        int num = 20;
        int sum = 0;
        int first =1;
        int second = 1;
        int next;
        System.out.print("斐波那契数列前20项为：");

        for (int i = 0; i < num ; i++){
            System.out.print(first+" ");
            sum += first;
            next = first + second;
            first = second;
            second =next;

        }System.out.println();
        System.out.println("前20项斐波那契数列之和为："+sum);

    }
}
